package com.example.service;

import com.example.entity.MyPet;
import com.example.entity.Post;
import com.example.mapper.MyPetMapper;
import com.example.mapper.PostMapper;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/*
帖子业务处理
 */
@Service
public class MyPetService {

    @Resource
    private MyPetMapper myPetMapper;

    public void add(MyPet myPet) {
        myPetMapper.insert(myPet);
    }

    public void deleteById(Integer id) {
        myPetMapper.deleteById(id);
    }

    public void deleteBatch(List<Integer> ids) {
        for (Integer id : ids){
            this.deleteById(id);
        }
    }

    public void updateById(MyPet myPet) {
        myPetMapper.updateById(myPet);
    }

    public MyPet selectById(Integer id) {
        return myPetMapper.selectById(id);
    }

    public List<MyPet> selectAll(MyPet myPet) {
        return myPetMapper.selectAll(myPet);
    }

    public PageInfo<MyPet> selectPage(MyPet myPet, Integer pageNum, Integer pageSize) {
        PageHelper.startPage(pageNum, pageSize);
        List<MyPet> myPetList = myPetMapper.selectAll(myPet);
        return PageInfo.of(myPetList);
    }
}
